﻿namespace QLPhongKham.UC
{
    using DevExpress.Data;
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Mask;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraTab;
    using QLPhongKham.Access;
    using QLPhongKham.Access.BenhNhan;
    using QLPhongKham.BaseClass.BenhNhan;
    using QLPhongKham.Report;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;
    using UserControls;

    public class ucbn_chidinh : XtraUserControl
    {
        private BNChiDinh _bnchidinh;
        private long _idql;
        private int _iiddangnhap;
        private int _loaibn;
        private General _xuli;
        private SimpleButton btnboqua;
        private SimpleButton btnhuy;
        private SimpleButton btnin;
        private SimpleButton btnketthuc;
        private SimpleButton btnluu;
        private SimpleButton btnmoi;
        private SimpleButton btnsua;
        private LookUpEdit cbbphong;
        private IContainer components;
        private ctrdanhsach ctrdanhsach_vp;
        private DateEdit datechidinh;
        private GridControl gridds;
        private GridColumn gridds_dongia;
        private GridColumn gridds_dvt;
        private GridColumn gridds_ghichu;
        private GridColumn gridds_id;
        private GridColumn gridds_idchidinh;
        private GridColumn gridds_ma;
        private GridColumn gridds_sldathanhtoan;
        private GridColumn gridds_soluong;
        private GridColumn gridds_ten;
        private GridColumn gridds_thanhtien;
        private GridView gridView1;
        private Label label1;
        private Label label10;
        private Label label11;
        private Label label3;
        private Label label5;
        private Label label6;
        private Label label8;
        private Label label9;
        private Label lblmaso;
        private RepositoryItemTextEdit repositoryItemTextEdit1;
        private RepositoryItemTextEdit repositoryItemTextEdit2;
        private TextEdit txtchandoan;
        private TextEdit txtdongia;
        private TextEdit txtdvt;
        private TextEdit txthoten;
        private TextEdit txtma;
        private TextEdit txtmabn;
        private TextEdit txtnguoinhap;
        private TextEdit txtsoluong;
        private TextEdit txtten;

        public ucbn_chidinh()
        {
            this._loaibn = 1;
            this._idql = 0L;
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = new General();
        }

        public ucbn_chidinh(General xuli, int iddangnhap)
        {
            this._loaibn = 1;
            this._idql = 0L;
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = xuli;
            this._iiddangnhap = iddangnhap;
        }

        public ucbn_chidinh(General xuli, long idql, int loaibn)
        {
            this._loaibn = 1;
            this._idql = 0L;
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = xuli;
            this._idql = idql;
            this._loaibn = loaibn;
        }

        private void btnboqua_Click(object sender, EventArgs e)
        {
            this.f_Control_enable(false);
            this.f_loaddata_chidinh(this._idql);
        }

        private void btnin_Click(object sender, EventArgs e)
        {
            dtoBNThongTinBN nbn = new dtoBNThongTinBN {
                MABN = this.txtmabn.Text
            };
            nbn.Load();
            DataTable table2 = new BNChiDinh().f_loaddata_chidinh(this.txtmabn.Text, false).Copy();
            table2.Columns.Add("hoten");
            table2.Columns.Add("namsinh");
            table2.Columns.Add("phai");
            table2.Columns.Add("diachi");
            table2.Columns.Add("tenkp");
            table2.Columns.Add("makp");
            table2.Columns.Add("chandoan");
            table2.Columns.Add("nguoinhap");
            for (int i = 0; i < table2.Rows.Count; i++)
            {
                table2.Rows[i]["hoten"] = nbn.HOTEN;
                table2.Rows[i]["namsinh"] = nbn.NAMSINH.ToString();
                table2.Rows[i]["phai"] = (nbn.IDGIOITINH == 0) ? "Nam" : "Nữ";
                table2.Rows[i]["diachi"] = nbn.DIACHI;
                table2.Rows[i]["tenkp"] = this.cbbphong.Text;
                table2.Rows[i]["makp"] = this.cbbphong.EditValue.ToString();
                table2.Rows[i]["chandoan"] = this.txtchandoan.Text;
                table2.Rows[i]["nguoinhap"] = this.txtnguoinhap.Text;
            }
            DataSet data = new DataSet();
            data.Tables.Add(table2.Copy());
            data.WriteXml("dataxml//chidinh.xml", XmlWriteMode.WriteSchema);
            new XtraReport1().f_load(data, "repx_inphieuchidinh.repx");
        }

        private void btnketthuc_Click(object sender, EventArgs e)
        {
            try
            {
                XtraTabPage parent = (XtraTabPage) base.Parent;
                XtraTabControl control = (XtraTabControl) parent.Parent;
                control.TabPages.Remove(parent);
            }
            catch
            {
                XtraUserControl control2 = (XtraUserControl) base.Parent;
                control2.Controls.Remove(this);
            }
        }

        private void btnluu_Click(object sender, EventArgs e)
        {
            dtoBNChiDinh dinh = new dtoBNChiDinh(this._xuli.pConFigData);
            DataTable dataSource = (DataTable) this.gridds.DataSource;
            for (int i = 0; i < dataSource.Rows.Count; i++)
            {
                dinh = new dtoBNChiDinh(this._xuli.pConFigData) {
                    pIDDOITUONG = 1,
                    pIDPHONG = int.Parse(this.cbbphong.EditValue.ToString()),
                    pIDQL = this._idql,
                    pIDVP = decimal.Parse(dataSource.Rows[i][this.gridds_id.FieldName].ToString()),
                    pMABN = this.txtmabn.Text,
                    pNGAY = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                    pSOLUONG = int.Parse(dataSource.Rows[i][this.gridds_soluong.FieldName].ToString()),
                    pDONGIA = decimal.Parse(dataSource.Rows[i][this.gridds_dongia.FieldName].ToString()),
                    pID = decimal.Parse(dataSource.Rows[i][this.gridds_idchidinh.FieldName].ToString()),
                    pIDDANGNHAP = this._iiddangnhap
                };
                if (dinh.pID == 0M)
                {
                    dinh.pID = long.Parse(this._xuli.f_Get_CapID());
                    if (!dinh.Insert())
                    {
                        MessageBox.Show("Kh\x00f4ng cập nhật được chỉ định viện ph\x00ed.\nVui l\x00f2ng kiểm tra lại.", "Th\x00f4ng b\x00e1o");
                        return;
                    }
                }
                else if (!dinh.Update())
                {
                    MessageBox.Show("Kh\x00f4ng cập nhật được chỉ định viện ph\x00ed.\nVui l\x00f2ng kiểm tra lại.", "Th\x00f4ng b\x00e1o");
                    return;
                }
            }
            this.f_Control_enable(false);
        }

        private void btnmoi_Click(object sender, EventArgs e)
        {
            this.f_Add_ChiTiet();
            this.f_Loadcontrol_dmvp(0L, "", "", "", 0M);
            this.f_Loadcontrol_chidinhchitiet(0L, 1M, 0M);
            this.txtsoluong.EditValue = 1;
            base.ActiveControl = this.txtma;
        }

        private void btnsua_Click(object sender, EventArgs e)
        {
            this.f_Control_enable(true);
            this.txtma.Focus();
            this.txtsoluong.EditValue = 1;
        }

        private void btnxoa_Click(object sender, EventArgs e)
        {
            try
            {
                dtoBNChiDinh cd = new dtoBNChiDinh(this._xuli.pConFigData) {
                    pID = decimal.Parse(this.lblmaso.Tag.ToString())
                };
                cd.Load();
                if (cd.pID != 0M)
                {
                    if (cd.pSLDATHANHTOAN > 0)
                    {
                        MessageBox.Show("Kh\x00f4ng cho ph\x00e9p hủy chỉ định đ\x00e3 thu tiền.", "Th\x00f4ng b\x00e1o");
                    }
                    else if (MessageBox.Show("Bạn c\x00f3 chắc chắn muốn hủy chỉ định:\n" + this.txtma.Text + " - " + this.txtten.Text + " ?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.No)
                    {
                        if (!this._bnchidinh.f_delete_chidinh(cd))
                        {
                            MessageBox.Show("X\x00f3a kh\x00f4ng th\x00e0nh c\x00f4ng.Vui l\x00f2ng kiểm tra lại.", "Th\x00f4ng b\x00e1o");
                        }
                        else
                        {
                            MessageBox.Show("Đ\x00e3 x\x00f3a th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o");
                            this.f_loaddata_chidinh(this.txtmabn.Text);
                        }
                    }
                }
            }
            catch
            {
            }
        }

        private void btnxoa_Click_1(object sender, EventArgs e)
        {
            try
            {
                this.gridView1.DeleteSelectedRows();
            }
            catch
            {
            }
        }

        private void ctrdanhsach_vp_Validated(object sender, EventArgs e)
        {
            try
            {
                DataTable dongHienTai = this.ctrdanhsach_vp.DongHienTai;
                this.f_SetControl_dmsanpham(long.Parse(dongHienTai.Rows[0]["id"].ToString()));
            }
            catch
            {
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void f_Add_ChiTiet()
        {
            if ((this.txtma.Tag != null) && (this.txtma.Tag.ToString() != "0"))
            {
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                DataRow row = dataSource.NewRow();
                row[this.gridds_idchidinh.FieldName] = 0;
                row[this.gridds_ma.FieldName] = this.txtma.Text;
                row[this.gridds_ten.FieldName] = this.txtten.Text;
                row[this.gridds_dvt.FieldName] = this.txtdvt.Text;
                row[this.gridds_id.FieldName] = this.txtma.Tag.ToString();
                row[this.gridds_soluong.FieldName] = this.txtsoluong.Text;
                row[this.gridds_dongia.FieldName] = this.txtdongia.EditValue.ToString();
                row[this.gridds_thanhtien.FieldName] = decimal.Parse(row[this.gridds_dongia.FieldName].ToString()) * decimal.Parse(row[this.gridds_soluong.FieldName].ToString());
                row[this.gridds_sldathanhtoan.FieldName] = 0;
                DataRow[] rowArray = ((DataTable) this.gridds.DataSource).Select(this.gridds_id.FieldName + "=" + row[this.gridds_id.FieldName].ToString());
                if (rowArray.Length > 0)
                {
                    if (decimal.Parse(rowArray[0][this.gridds_sldathanhtoan.FieldName].ToString()) != 0M)
                    {
                        MessageBox.Show("T\x00ean viện ph\x00ed '" + row[this.gridds_ten.FieldName].ToString().ToUpper() + "' đ\x00e3 thanh to\x00e1n.\nKh\x00f4ng cập nhật lại th\x00f4ng tin viện ph\x00ed n\x00e0y.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else if (MessageBox.Show("T\x00ean viện ph\x00ed '" + row[this.gridds_ten.FieldName].ToString().ToUpper() + "' đ\x00e3 tồn tại.\nBạn c\x00f3 muốn cập nhật lại th\x00f4ng tin viện ph\x00ed n\x00e0y kh\x00f4ng?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        rowArray[0][this.gridds_dongia.FieldName] = row[this.gridds_dongia.FieldName].ToString();
                        rowArray[0][this.gridds_soluong.FieldName] = row[this.gridds_soluong.FieldName].ToString();
                        rowArray[0][this.gridds_thanhtien.FieldName] = row[this.gridds_thanhtien.FieldName].ToString();
                    }
                }
                else
                {
                    dataSource.Rows.Add(row);
                }
                this.gridds.DataSource = dataSource;
            }
        }

        private void f_Control_enable(bool chophep)
        {
            this.btnluu.Enabled = this.btnboqua.Enabled = this.btnmoi.Enabled = chophep;
            this.btnhuy.Enabled = this.btnsua.Enabled = this.btnketthuc.Enabled = !chophep;
        }

        private void f_load_khoaphong()
        {
            try
            {
                this.cbbphong.Properties.DataSource = new BNDanhMuc(this._xuli.pConFigData).f_loaddata_bn_dmphong(false);
                this.cbbphong.Properties.DisplayMember = "ten";
                this.cbbphong.Properties.ValueMember = "id";
                this.cbbphong.ItemIndex = 0;
            }
            catch
            {
            }
        }

        private void f_Loadcontrol_chidinhchitiet(long id, decimal soluong, decimal dongia)
        {
            this.lblmaso.Tag = id.ToString();
            this.txtsoluong.EditValue = soluong;
            this.txtdongia.EditValue = dongia;
        }

        private void f_Loadcontrol_dmvp(long id, string ma, string ten, string dvt, decimal dongia)
        {
            this.txtma.Text = ma;
            this.txtma.Tag = id.ToString();
            this.txtten.Text = ten;
            this.txtdvt.Text = dvt;
            this.txtdongia.EditValue = dongia;
        }

        private void f_loadControl_thongtinbenhnhan(long idql, string mabn, string hoten, int idphong, string ngay, string chandoan, string tennguoinhap)
        {
            this.txtmabn.Tag = idql.ToString();
            this.txtmabn.Text = mabn;
            this.txthoten.Text = hoten;
            this.cbbphong.EditValue = idphong;
            try
            {
                this.datechidinh.EditValue = new DateTime(int.Parse(ngay.Substring(6, 4)), int.Parse(ngay.Substring(3, 2)), int.Parse(ngay.Substring(0, 2)), int.Parse(ngay.Substring(11, 2)), int.Parse(ngay.Substring(14, 2)), 0);
            }
            catch
            {
            }
            this.txtchandoan.Text = chandoan;
            this.txtnguoinhap.Text = tennguoinhap;
        }

        private void f_loaddata_chidinh(long idql)
        {
            DataTable table = this._bnchidinh.f_loaddata_chidinh(idql, false);
            this.gridds.DataSource = table;
        }

        private void f_loaddata_chidinh(string mabn)
        {
            DataTable table = this._bnchidinh.f_loaddata_chidinh(mabn, false);
            this.gridds.DataSource = table;
        }

        private void f_Loaddata_dmvp()
        {
            try
            {
                this.ctrdanhsach_vp.SetDataSource = new BNDanhMuc(this._xuli.pConFigData).f_loaddata_vp_giavp();
                this.ctrdanhsach_vp.DanhSachCotHienThi = "ma,ten,dvt,dongia";
            }
            catch
            {
            }
        }

        private void f_loadData_thongtinloaibn(int loaibn)
        {
            try
            {
                DataTable table = new DataTable();
                try
                {
                    table = new BNTiepDon(this._xuli.pConFigData).f_loaddata_bntiepdon(this._idql);
                    this.f_loadControl_thongtinbenhnhan(long.Parse(table.Rows[0]["idql"].ToString()), table.Rows[0]["mabn"].ToString(), table.Rows[0]["hoten"].ToString(), int.Parse(table.Rows[0]["idphong"].ToString()), table.Rows[0]["ngay"].ToString(), "", table.Rows[0]["tennguoinhap"].ToString());
                }
                catch
                {
                }
                try
                {
                    table = new BNKhamBenh(this._xuli.pConFigData).f_loaddata_bnkhambenh(this._idql);
                    this.f_loadControl_thongtinbenhnhan(long.Parse(table.Rows[0]["idql"].ToString()), table.Rows[0]["mabn"].ToString(), table.Rows[0]["hoten"].ToString(), int.Parse(table.Rows[0]["idphong"].ToString()), table.Rows[0]["ngay"].ToString(), table.Rows[0]["chandoan"].ToString(), table.Rows[0]["tennguoinhap"].ToString());
                }
                catch
                {
                }
            }
            catch
            {
            }
        }

        private void f_loadinfo_chidinhchitiet(int indexrow)
        {
            try
            {
                this.f_Loadcontrol_dmvp(long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_id).ToString()), this.gridView1.GetRowCellValue(indexrow, this.gridds_ma).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_ten).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_dvt).ToString(), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_dongia).ToString()));
                this.f_Loadcontrol_chidinhchitiet(long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_idchidinh).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_soluong).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_dongia).ToString()));
            }
            catch
            {
            }
        }

        private void f_SetControl_dmsanpham(long idvp)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_vp.SetDataSource.Select("id=" + idvp.ToString());
                this.f_Loadcontrol_dmvp(idvp, rowArray[0]["ma"].ToString(), rowArray[0]["ten"].ToString(), rowArray[0]["dvt"].ToString(), decimal.Parse(rowArray[0]["dongia"].ToString()));
            }
            catch
            {
                this.f_Loadcontrol_dmvp(0L, "", "", "", 0M);
            }
        }

        private void gridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
        {
            try
            {
                if (Convert.ToInt32(this.gridView1.GetRowCellValue(e.RowHandle, this.gridds_sldathanhtoan)) > 0M)
                {
                    e.Appearance.ForeColor = Color.Red;
                }
            }
            catch
            {
            }
        }

        private void gridView1_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
        {
        }

        private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            int indexrow = 0;
            try
            {
                if (!this.btnluu.Enabled)
                {
                    indexrow = this.gridView1.GetSelectedRows()[0];
                    this.f_loadinfo_chidinhchitiet(indexrow);
                }
            }
            catch
            {
            }
        }

        private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            try
            {
                GridView view = sender as GridView;
                if (Convert.ToDecimal(view.GetRowCellValue(e.RowHandle, this.gridds_sldathanhtoan.FieldName).ToString()) > 0M)
                {
                    e.Appearance.ForeColor = Color.Red;
                }
            }
            catch
            {
            }
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ucbn_chidinh));
            StyleFormatCondition condition = new StyleFormatCondition();
            this.gridds_dongia = new GridColumn();
            this.repositoryItemTextEdit2 = new RepositoryItemTextEdit();
            this.lblmaso = new Label();
            this.txtma = new TextEdit();
            this.label3 = new Label();
            this.txtten = new TextEdit();
            this.txtdvt = new TextEdit();
            this.label5 = new Label();
            this.txtsoluong = new TextEdit();
            this.btnmoi = new SimpleButton();
            this.btnluu = new SimpleButton();
            this.btnhuy = new SimpleButton();
            this.btnketthuc = new SimpleButton();
            this.gridView1 = new GridView();
            this.gridds_ma = new GridColumn();
            this.repositoryItemTextEdit1 = new RepositoryItemTextEdit();
            this.gridds_ten = new GridColumn();
            this.gridds_dvt = new GridColumn();
            this.gridds_id = new GridColumn();
            this.gridds_soluong = new GridColumn();
            this.gridds_thanhtien = new GridColumn();
            this.gridds_ghichu = new GridColumn();
            this.gridds_idchidinh = new GridColumn();
            this.gridds_sldathanhtoan = new GridColumn();
            this.gridds = new GridControl();
            this.btnboqua = new SimpleButton();
            this.label1 = new Label();
            this.txtmabn = new TextEdit();
            this.label6 = new Label();
            this.txthoten = new TextEdit();
            this.label8 = new Label();
            this.datechidinh = new DateEdit();
            this.ctrdanhsach_vp = new ctrdanhsach();
            this.label9 = new Label();
            this.cbbphong = new LookUpEdit();
            this.label10 = new Label();
            this.txtchandoan = new TextEdit();
            this.label11 = new Label();
            this.txtnguoinhap = new TextEdit();
            this.btnin = new SimpleButton();
            this.btnsua = new SimpleButton();
            this.txtdongia = new TextEdit();
            this.repositoryItemTextEdit2.BeginInit();
            this.txtma.Properties.BeginInit();
            this.txtten.Properties.BeginInit();
            this.txtdvt.Properties.BeginInit();
            this.txtsoluong.Properties.BeginInit();
            this.gridView1.BeginInit();
            this.repositoryItemTextEdit1.BeginInit();
            this.gridds.BeginInit();
            this.txtmabn.Properties.BeginInit();
            this.txthoten.Properties.BeginInit();
            this.datechidinh.Properties.VistaTimeProperties.BeginInit();
            this.datechidinh.Properties.BeginInit();
            this.cbbphong.Properties.BeginInit();
            this.txtchandoan.Properties.BeginInit();
            this.txtnguoinhap.Properties.BeginInit();
            this.txtdongia.Properties.BeginInit();
            base.SuspendLayout();
            this.gridds_dongia.Caption = "Đơn gi\x00e1";
            this.gridds_dongia.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_dongia.FieldName = "dongia";
            this.gridds_dongia.Name = "gridds_dongia";
            this.gridds_dongia.Visible = true;
            this.gridds_dongia.VisibleIndex = 3;
            this.gridds_dongia.Width = 0x39;
            this.repositoryItemTextEdit2.AutoHeight = false;
            this.repositoryItemTextEdit2.DisplayFormat.FormatString = "n0";
            this.repositoryItemTextEdit2.DisplayFormat.FormatType = FormatType.Numeric;
            this.repositoryItemTextEdit2.EditFormat.FormatType = FormatType.Numeric;
            this.repositoryItemTextEdit2.Mask.EditMask = "n0";
            this.repositoryItemTextEdit2.Mask.MaskType = MaskType.Numeric;
            this.repositoryItemTextEdit2.Name = "repositoryItemTextEdit2";
            this.lblmaso.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.lblmaso.Font = new Font("Tahoma", 10f);
            this.lblmaso.Location = new Point(4, 0x164);
            this.lblmaso.Name = "lblmaso";
            this.lblmaso.Size = new Size(70, 0x13);
            this.lblmaso.TabIndex = 2;
            this.lblmaso.Text = "M\x00e3 số:";
            this.lblmaso.TextAlign = ContentAlignment.TopRight;
            this.txtma.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtma.Location = new Point(0x49, 0x163);
            this.txtma.Name = "txtma";
            this.txtma.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtma.Size = new Size(100, 20);
            this.txtma.TabIndex = 6;
            this.txtma.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.txtma.Validated += new EventHandler(this.txtma_Validated);
            this.label3.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label3.Font = new Font("Tahoma", 10f);
            this.label3.Location = new Point(0xa9, 0x164);
            this.label3.Name = "label3";
            this.label3.Size = new Size(50, 0x13);
            this.label3.TabIndex = 2;
            this.label3.Text = "T\x00ean:";
            this.label3.TextAlign = ContentAlignment.TopRight;
            this.txtten.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtten.Location = new Point(0xd7, 0x163);
            this.txtten.Name = "txtten";
            this.txtten.Size = new Size(0x138, 20);
            this.txtten.TabIndex = 7;
            this.txtten.TextChanged += new EventHandler(this.txtten_TextChanged);
            this.txtten.Enter += new EventHandler(this.txtten_Enter);
            this.txtten.KeyDown += new KeyEventHandler(this.txtten_KeyDown);
            this.txtten.Validated += new EventHandler(this.txtten_Validated);
            this.txtdvt.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txtdvt.EditValue = "";
            this.txtdvt.Enabled = false;
            this.txtdvt.Location = new Point(0x281, 0x163);
            this.txtdvt.Name = "txtdvt";
            this.txtdvt.Size = new Size(0x2e, 20);
            this.txtdvt.TabIndex = 10;
            this.txtdvt.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label5.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.label5.Font = new Font("Tahoma", 10f);
            this.label5.Location = new Point(530, 0x164);
            this.label5.Name = "label5";
            this.label5.Size = new Size(70, 0x13);
            this.label5.TabIndex = 2;
            this.label5.Text = "Số lượng:";
            this.label5.TextAlign = ContentAlignment.TopRight;
            this.txtsoluong.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txtsoluong.EditValue = (short) 0;
            this.txtsoluong.Location = new Point(0x257, 0x163);
            this.txtsoluong.Name = "txtsoluong";
            this.txtsoluong.Size = new Size(40, 20);
            this.txtsoluong.TabIndex = 9;
            this.txtsoluong.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.btnmoi.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnmoi.Appearance.Options.UseTextOptions = true;
            this.btnmoi.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnmoi.Image = Properties.Resources.imgnew;// (Image)manager.GetObject("btnmoi.Image");
            this.btnmoi.Location = new Point(4, 0x185);
            this.btnmoi.Name = "btnmoi";
            this.btnmoi.Size = new Size(0x4b, 0x17);
            this.btnmoi.TabIndex = 13;
            this.btnmoi.Text = " &Th\x00eam [F1]";
            this.btnmoi.Click += new EventHandler(this.btnmoi_Click);
            this.btnluu.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnluu.Appearance.Options.UseTextOptions = true;
            this.btnluu.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnluu.Image = Properties.Resources.imgsave;// (Image)manager.GetObject("btnluu.Image");
            this.btnluu.Location = new Point(0x51, 0x185);
            this.btnluu.Name = "btnluu";
            this.btnluu.Size = new Size(0x4b, 0x17);
            this.btnluu.TabIndex = 14;
            this.btnluu.Text = " &Lưu [F5]";
            this.btnluu.Click += new EventHandler(this.btnluu_Click);
            this.btnhuy.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnhuy.Image = (Image) manager.GetObject("btnhuy.Image");
            this.btnhuy.Location = new Point(330, 0x185);
            this.btnhuy.Name = "btnhuy";
            this.btnhuy.Size = new Size(0x3b, 0x17);
            this.btnhuy.TabIndex = 0x11;
            this.btnhuy.Text = " &Hủy";
            this.btnhuy.Click += new EventHandler(this.btnxoa_Click);
            this.btnketthuc.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btnketthuc.Appearance.Options.UseTextOptions = true;
            this.btnketthuc.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnketthuc.Image = Properties.Resources.imgclose;// (Image)manager.GetObject("btnketthuc.Image");
            this.btnketthuc.Location = new Point(680, 0x185);
            this.btnketthuc.Name = "btnketthuc";
            this.btnketthuc.Size = new Size(0x65, 0x17);
            this.btnketthuc.TabIndex = 0x13;
            this.btnketthuc.Text = " &Kết th\x00fac [F12]";
            this.btnketthuc.Click += new EventHandler(this.btnketthuc_Click);
            this.gridView1.Appearance.ColumnFilterButton.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.ColumnFilterButton.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.ColumnFilterButton.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseForeColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.BackColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.ColumnFilterButtonActive.BorderColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.ColumnFilterButtonActive.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseForeColor = true;
            this.gridView1.Appearance.Empty.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.Empty.BackColor2 = Color.White;
            this.gridView1.Appearance.Empty.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.BackColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.EvenRow.BorderColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.EvenRow.ForeColor = Color.Black;
            this.gridView1.Appearance.EvenRow.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterCloseButton.BackColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.FilterCloseButton.BorderColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.FilterCloseButton.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterPanel.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.FilterPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.FilterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.FixedLine.BackColor = Color.FromArgb(0x7a, 0x72, 0x71);
            this.gridView1.Appearance.FixedLine.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.BackColor = Color.White;
            this.gridView1.Appearance.FocusedCell.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedCell.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.Options.UseForeColor = true;
            this.gridView1.Appearance.FocusedRow.BackColor = Color.FromArgb(200, 0xc0, 0x9d);
            this.gridView1.Appearance.FocusedRow.BorderColor = Color.FromArgb(0xe2, 0xdb, 0xbc);
            this.gridView1.Appearance.FocusedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FooterPanel.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.FooterPanel.BorderColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.FooterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FooterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupButton.BackColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.GroupButton.BorderColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.GroupButton.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupFooter.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupFooter.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupFooter.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupPanel.BackColor = Color.FromArgb(0xf6, 0xf2, 0xd5);
            this.gridView1.Appearance.GroupPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.GroupPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupRow.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupRow.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupRow.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupRow.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HeaderPanel.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HeaderPanel.BorderColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HeaderPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.HideSelectionRow.BackColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.HideSelectionRow.BorderColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.HideSelectionRow.ForeColor = Color.Black;
            this.gridView1.Appearance.HideSelectionRow.Options.UseBackColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HorzLine.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HorzLine.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.BorderColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.ForeColor = Color.Black;
            this.gridView1.Appearance.OddRow.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.Options.UseForeColor = true;
            this.gridView1.Appearance.Preview.BackColor = Color.FromArgb(0xfb, 0xfc, 0xf7);
            this.gridView1.Appearance.Preview.Font = new Font("Verdana", 7.5f);
            this.gridView1.Appearance.Preview.ForeColor = Color.FromArgb(0x94, 0x94, 0x94);
            this.gridView1.Appearance.Preview.Options.UseBackColor = true;
            this.gridView1.Appearance.Preview.Options.UseFont = true;
            this.gridView1.Appearance.Preview.Options.UseForeColor = true;
            this.gridView1.Appearance.Row.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Row.ForeColor = Color.Black;
            this.gridView1.Appearance.Row.Options.UseBackColor = true;
            this.gridView1.Appearance.Row.Options.UseForeColor = true;
            this.gridView1.Appearance.RowSeparator.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.RowSeparator.BackColor2 = Color.White;
            this.gridView1.Appearance.RowSeparator.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.BackColor = Color.FromArgb(0xdd, 0xd7, 0xbc);
            this.gridView1.Appearance.SelectedRow.BorderColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.SelectedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.SelectedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.TopNewRow.BackColor = Color.White;
            this.gridView1.Appearance.TopNewRow.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.VertLine.Options.UseBackColor = true;
            this.gridView1.Columns.AddRange(new GridColumn[] { this.gridds_ma, this.gridds_ten, this.gridds_dvt, this.gridds_id, this.gridds_dongia, this.gridds_soluong, this.gridds_thanhtien, this.gridds_ghichu, this.gridds_idchidinh, this.gridds_sldathanhtoan });
            condition.Appearance.ForeColor = Color.Red;
            condition.Appearance.Options.UseForeColor = true;
            condition.Column = this.gridds_dongia;
            condition.Condition = FormatConditionEnum.Between;
            condition.Value1 = "0";
            condition.Value2 = "0";
            this.gridView1.FormatConditions.AddRange(new StyleFormatCondition[] { condition });
            this.gridView1.GridControl = this.gridds;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsBehavior.AllowAddRows = DefaultBoolean.True;
            this.gridView1.OptionsBehavior.AllowDeleteRows = DefaultBoolean.False;
            this.gridView1.OptionsBehavior.ReadOnly = true;
            this.gridView1.OptionsView.AutoCalcPreviewLineCount = true;
            this.gridView1.OptionsView.EnableAppearanceEvenRow = true;
            this.gridView1.OptionsView.EnableAppearanceOddRow = true;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowFooter = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.gridView1.CustomDrawCell += new RowCellCustomDrawEventHandler(this.gridView1_CustomDrawCell);
            this.gridView1.RowCellStyle += new RowCellStyleEventHandler(this.gridView1_RowCellStyle);
            this.gridView1.CustomSummaryCalculate += new CustomSummaryEventHandler(this.gridView1_CustomSummaryCalculate);
            this.gridView1.FocusedRowChanged += new FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged);
            this.gridView1.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.gridds_ma.Caption = "M\x00e3 số";
            this.gridds_ma.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ma.FieldName = "mavp";
            this.gridds_ma.Name = "gridds_ma";
            this.gridds_ma.OptionsColumn.AllowEdit = false;
            this.gridds_ma.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Count, "ma", "Tổng cộng={0:n0}") });
            this.gridds_ma.Visible = true;
            this.gridds_ma.VisibleIndex = 0;
            this.gridds_ma.Width = 0x5b;
            this.repositoryItemTextEdit1.AutoHeight = false;
            this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            this.repositoryItemTextEdit1.ReadOnly = true;
            this.gridds_ten.Caption = "T\x00ean viện ph\x00ed";
            this.gridds_ten.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ten.FieldName = "tenvp";
            this.gridds_ten.Name = "gridds_ten";
            this.gridds_ten.OptionsColumn.AllowEdit = false;
            this.gridds_ten.Visible = true;
            this.gridds_ten.VisibleIndex = 1;
            this.gridds_ten.Width = 0x12e;
            this.gridds_dvt.Caption = "ĐVT";
            this.gridds_dvt.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_dvt.FieldName = "dvt";
            this.gridds_dvt.Name = "gridds_dvt";
            this.gridds_dvt.OptionsColumn.AllowEdit = false;
            this.gridds_dvt.Visible = true;
            this.gridds_dvt.VisibleIndex = 2;
            this.gridds_dvt.Width = 0x23;
            this.gridds_id.Caption = "id";
            this.gridds_id.FieldName = "idvp";
            this.gridds_id.Name = "gridds_id";
            this.gridds_soluong.Caption = "SL";
            this.gridds_soluong.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_soluong.FieldName = "soluong";
            this.gridds_soluong.Name = "gridds_soluong";
            this.gridds_soluong.Visible = true;
            this.gridds_soluong.VisibleIndex = 4;
            this.gridds_soluong.Width = 0x19;
            this.gridds_thanhtien.Caption = "Th\x00e0nh tiền";
            this.gridds_thanhtien.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_thanhtien.FieldName = "thanhtien";
            this.gridds_thanhtien.Name = "gridds_thanhtien";
            this.gridds_thanhtien.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Sum, "thanhtien", "Tổng tiền: {0:n0}") });
            this.gridds_thanhtien.Visible = true;
            this.gridds_thanhtien.VisibleIndex = 5;
            this.gridds_thanhtien.Width = 0x54;
            this.gridds_ghichu.Caption = "Ghi ch\x00fa";
            this.gridds_ghichu.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ghichu.FieldName = "ghichu";
            this.gridds_ghichu.Name = "gridds_ghichu";
            this.gridds_ghichu.OptionsColumn.AllowEdit = false;
            this.gridds_ghichu.Visible = true;
            this.gridds_ghichu.VisibleIndex = 6;
            this.gridds_ghichu.Width = 0x8e;
            this.gridds_idchidinh.Caption = "idchidinh";
            this.gridds_idchidinh.FieldName = "id";
            this.gridds_idchidinh.Name = "gridds_idchidinh";
            this.gridds_sldathanhtoan.Caption = "sldathanhtoan";
            this.gridds_sldathanhtoan.FieldName = "sldathanhtoan";
            this.gridds_sldathanhtoan.Name = "gridds_sldathanhtoan";
            this.gridds.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.gridds.Location = new Point(3, 0x40);
            this.gridds.MainView = this.gridView1;
            this.gridds.Name = "gridds";
            this.gridds.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemTextEdit1, this.repositoryItemTextEdit2 });
            this.gridds.Size = new Size(0x30b, 0x11d);
            this.gridds.TabIndex = 0x12;
            this.gridds.ViewCollection.AddRange(new BaseView[] { this.gridView1 });
            this.btnboqua.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnboqua.Image = Properties.Resources.imgundo;// (Image)manager.GetObject("btnboqua.Image");
            this.btnboqua.Location = new Point(0xed, 0x185);
            this.btnboqua.Name = "btnboqua";
            this.btnboqua.Size = new Size(0x57, 0x17);
            this.btnboqua.TabIndex = 15;
            this.btnboqua.Text = " &Bỏ qua [F4]";
            this.btnboqua.Click += new EventHandler(this.btnboqua_Click);
            this.label1.Font = new Font("Tahoma", 10f);
            this.label1.Location = new Point(6, 13);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x3d, 0x13);
            this.label1.TabIndex = 2;
            this.label1.Text = "M\x00e3 BN:";
            this.label1.TextAlign = ContentAlignment.TopRight;
            this.txtmabn.Location = new Point(0x41, 12);
            this.txtmabn.Name = "txtmabn";
            this.txtmabn.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtmabn.Properties.MaxLength = 10;
            this.txtmabn.Size = new Size(0x76, 20);
            this.txtmabn.TabIndex = 0;
            this.txtmabn.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label6.Font = new Font("Tahoma", 10f);
            this.label6.Location = new Point(0xc3, 13);
            this.label6.Name = "label6";
            this.label6.Size = new Size(70, 0x13);
            this.label6.TabIndex = 2;
            this.label6.Text = "Họ t\x00ean:";
            this.label6.TextAlign = ContentAlignment.TopRight;
            this.txthoten.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txthoten.Location = new Point(0x106, 12);
            this.txthoten.Name = "txthoten";
            this.txthoten.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txthoten.Size = new Size(0x10a, 20);
            this.txthoten.TabIndex = 1;
            this.txthoten.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label8.Font = new Font("Tahoma", 10f);
            this.label8.Location = new Point(11, 0x27);
            this.label8.Name = "label8";
            this.label8.Size = new Size(0x38, 0x13);
            this.label8.TabIndex = 2;
            this.label8.Text = "Ng\x00e0y:";
            this.label8.TextAlign = ContentAlignment.TopRight;
            this.datechidinh.EditValue = new DateTime(0x7dd, 11, 8, 2, 0x16, 9, 0x297);
            this.datechidinh.Location = new Point(0x41, 0x26);
            this.datechidinh.Name = "datechidinh";
            this.datechidinh.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.datechidinh.Properties.DisplayFormat.FormatString = "dd/MM/yyyy HH:mm";
            this.datechidinh.Properties.DisplayFormat.FormatType = FormatType.DateTime;
            this.datechidinh.Properties.EditFormat.FormatString = "dd/MM/yyyy HH:mm";
            this.datechidinh.Properties.EditFormat.FormatType = FormatType.DateTime;
            this.datechidinh.Properties.Mask.EditMask = "dd/MM/yyyy HH:mm";
            this.datechidinh.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.datechidinh.Size = new Size(0x76, 20);
            this.datechidinh.TabIndex = 3;
            this.ctrdanhsach_vp.ChieuRongTuDong = true;
            this.ctrdanhsach_vp.DanhSachCotHienThi = "";
            this.ctrdanhsach_vp.DanhSachCotHienThi_kt = "";
            this.ctrdanhsach_vp.Location = new Point(0x257, 0x185);
            this.ctrdanhsach_vp.Name = "ctrdanhsach_vp";
            this.ctrdanhsach_vp.pRowsCountDown = 5;
            this.ctrdanhsach_vp.Size = new Size(60, 0x13);
            this.ctrdanhsach_vp.TabIndex = 8;
            this.ctrdanhsach_vp.Visible = false;
            this.ctrdanhsach_vp.Validated += new EventHandler(this.ctrdanhsach_vp_Validated);
            this.label9.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label9.Font = new Font("Tahoma", 10f);
            this.label9.Location = new Point(0x216, 13);
            this.label9.Name = "label9";
            this.label9.Size = new Size(0x5c, 0x13);
            this.label9.TabIndex = 2;
            this.label9.Text = "Khoa/Ph\x00f2ng:";
            this.label9.TextAlign = ContentAlignment.TopRight;
            this.cbbphong.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.cbbphong.Location = new Point(0x26e, 12);
            this.cbbphong.Name = "cbbphong";
            this.cbbphong.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cbbphong.Properties.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("id", "id"), new LookUpColumnInfo("ten", "T\x00ean ph\x00f2ng") });
            this.cbbphong.Size = new Size(160, 20);
            this.cbbphong.TabIndex = 2;
            this.label10.Font = new Font("Tahoma", 10f);
            this.label10.Location = new Point(0xb2, 0x27);
            this.label10.Name = "label10";
            this.label10.Size = new Size(0x57, 0x13);
            this.label10.TabIndex = 2;
            this.label10.Text = "Chẩn đo\x00e1n:";
            this.label10.TextAlign = ContentAlignment.TopRight;
            this.txtchandoan.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtchandoan.Location = new Point(0x106, 0x26);
            this.txtchandoan.Name = "txtchandoan";
            this.txtchandoan.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtchandoan.Size = new Size(0x10a, 20);
            this.txtchandoan.TabIndex = 4;
            this.txtchandoan.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label11.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label11.Font = new Font("Tahoma", 10f);
            this.label11.Location = new Point(0x216, 0x27);
            this.label11.Name = "label11";
            this.label11.Size = new Size(0x5c, 0x13);
            this.label11.TabIndex = 2;
            this.label11.Text = "Người nhập:";
            this.label11.TextAlign = ContentAlignment.TopRight;
            this.txtnguoinhap.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.txtnguoinhap.Location = new Point(0x26e, 0x26);
            this.txtnguoinhap.Name = "txtnguoinhap";
            this.txtnguoinhap.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtnguoinhap.Size = new Size(160, 20);
            this.txtnguoinhap.TabIndex = 5;
            this.txtnguoinhap.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.btnin.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnin.Image = Properties.Resources.imgprint;// (Image)manager.GetObject("btnin.Image");
            this.btnin.Location = new Point(0x18c, 0x185);
            this.btnin.Name = "btnin";
            this.btnin.Size = new Size(0x3d, 0x17);
            this.btnin.TabIndex = 0x11;
            this.btnin.Text = " &In";
            this.btnin.Click += new EventHandler(this.btnin_Click);
            this.btnsua.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.btnsua.Appearance.Options.UseTextOptions = true;
            this.btnsua.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnsua.Image = Properties.Resources.imgedit;// (Image)manager.GetObject("btnsua.Image");
            this.btnsua.Location = new Point(0x9f, 0x185);
            this.btnsua.Name = "btnsua";
            this.btnsua.Size = new Size(0x4b, 0x17);
            this.btnsua.TabIndex = 0x18;
            this.btnsua.Text = " &Sửa [F3]";
            this.btnsua.Click += new EventHandler(this.btnsua_Click);
            this.txtdongia.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txtdongia.Location = new Point(0x2b1, 0x161);
            this.txtdongia.Name = "txtdongia";
            this.txtdongia.Properties.Appearance.Font = new Font("Tahoma", 10f);
            this.txtdongia.Properties.Appearance.Options.UseFont = true;
            this.txtdongia.Properties.DisplayFormat.FormatString = "n2";
            this.txtdongia.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.txtdongia.Properties.EditFormat.FormatString = "n2";
            this.txtdongia.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.txtdongia.Properties.Mask.EditMask = "n2";
            this.txtdongia.Properties.Mask.MaskType = MaskType.Numeric;
            this.txtdongia.Size = new Size(0x5c, 0x16);
            this.txtdongia.TabIndex = 11;
            this.txtdongia.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.txtdongia);
            base.Controls.Add(this.btnsua);
            base.Controls.Add(this.ctrdanhsach_vp);
            base.Controls.Add(this.cbbphong);
            base.Controls.Add(this.datechidinh);
            base.Controls.Add(this.txtsoluong);
            base.Controls.Add(this.txtnguoinhap);
            base.Controls.Add(this.txtchandoan);
            base.Controls.Add(this.txthoten);
            base.Controls.Add(this.txtmabn);
            base.Controls.Add(this.txtma);
            base.Controls.Add(this.gridds);
            base.Controls.Add(this.btnketthuc);
            base.Controls.Add(this.btnin);
            base.Controls.Add(this.btnhuy);
            base.Controls.Add(this.btnboqua);
            base.Controls.Add(this.btnluu);
            base.Controls.Add(this.btnmoi);
            base.Controls.Add(this.txtten);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.txtdvt);
            base.Controls.Add(this.label11);
            base.Controls.Add(this.label10);
            base.Controls.Add(this.label9);
            base.Controls.Add(this.label6);
            base.Controls.Add(this.label8);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.label5);
            base.Controls.Add(this.lblmaso);
            base.Name = "ucbn_chidinh";
            base.Size = new Size(0x311, 0x19f);
            base.Load += new EventHandler(this.ucDMSanPham_Load);
            base.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.repositoryItemTextEdit2.EndInit();
            this.txtma.Properties.EndInit();
            this.txtten.Properties.EndInit();
            this.txtdvt.Properties.EndInit();
            this.txtsoluong.Properties.EndInit();
            this.gridView1.EndInit();
            this.repositoryItemTextEdit1.EndInit();
            this.gridds.EndInit();
            this.txtmabn.Properties.EndInit();
            this.txthoten.Properties.EndInit();
            this.datechidinh.Properties.VistaTimeProperties.EndInit();
            this.datechidinh.Properties.EndInit();
            this.cbbphong.Properties.EndInit();
            this.txtchandoan.Properties.EndInit();
            this.txtnguoinhap.Properties.EndInit();
            this.txtdongia.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void txtma_Validated(object sender, EventArgs e)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_vp.SetDataSource.Select("ma='" + this.txtma.Text + "'");
                this.f_SetControl_dmsanpham(long.Parse(rowArray[0]["id"].ToString()));
                if (rowArray.Length > 0)
                {
                    this.ctrdanhsach_vp.Visible = false;
                    this.txtsoluong.Focus();
                }
            }
            catch
            {
            }
        }

        private void txtten_Enter(object sender, EventArgs e)
        {
            this.ctrdanhsach_vp.Width = (this.txtdongia.Location.X + this.txtdongia.Width) - this.txtma.Location.X;
            this.ctrdanhsach_vp.DanhSachCotHienThi_kt = string.Concat(new object[] { this.txtten.Location.X - this.txtma.Location.X, ",", (((this.ctrdanhsach_vp.Width - 0x23) - this.txtten.Location.X) + this.txtma.Location.X) - this.txtdongia.Width, ",", 30, ",", this.txtdongia.Width });
            this.ctrdanhsach_vp.Location = new Point(this.txtma.Location.X, (this.txtma.Location.Y - this.ctrdanhsach_vp.Height) - 1);
        }

        private void txtten_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down))
            {
                if (this.ctrdanhsach_vp.Visible)
                {
                    this.ctrdanhsach_vp.Focus();
                }
            }
            else if (e.KeyCode == Keys.Escape)
            {
                this.ctrdanhsach_vp.Visible = false;
            }
            else
            {
                this.ctrdanhsach_vp.Visible = false;
                this.ucDMSanPham_KeyDown(sender, e);
            }
        }

        private void txtten_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (this.txtten.IsEditorActive)
                {
                    this.ctrdanhsach_vp.Visible = true;
                    this.ctrdanhsach_vp.Locdulieu(this.txtten.Text);
                }
            }
            catch
            {
            }
        }

        private void txtten_Validated(object sender, EventArgs e)
        {
            try
            {
            }
            catch
            {
            }
        }

        private void ucDMSanPham_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SendKeys.Send("{Tab}");
            }
            else if (e.KeyCode == Keys.F1)
            {
                if (this.btnmoi.Enabled)
                {
                    this.btnmoi_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F3)
            {
                if (this.btnsua.Enabled)
                {
                    this.btnsua_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F4)
            {
                if (this.btnboqua.Enabled)
                {
                    this.btnboqua_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F5)
            {
                if (this.btnluu.Enabled)
                {
                    this.btnluu_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F7)
            {
                if (this.btnhuy.Enabled)
                {
                    this.btnxoa_Click(null, null);
                }
            }
            else if ((e.KeyCode == Keys.F12) && this.btnketthuc.Enabled)
            {
                this.btnketthuc_Click(null, null);
            }
        }

        private void ucDMSanPham_Load(object sender, EventArgs e)
        {
            this._bnchidinh = new BNChiDinh(this._xuli.pConFigData);
            this.f_load_khoaphong();
            this.f_Loaddata_dmvp();
            this.f_loadData_thongtinloaibn(this._loaibn);
            if (this._idql == 0L)
            {
                this.f_loaddata_chidinh(this.txtmabn.Text);
            }
            else
            {
                this.f_loaddata_chidinh(this._idql);
            }
            this.btnboqua_Click(null, null);
            this.f_loadinfo_chidinhchitiet(0);
            try
            {
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                if (dataSource.Rows.Count == 0)
                {
                    this.btnsua_Click(null, null);
                }
            }
            catch
            {
            }
        }
    }
}

